home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / Python 1.3 PPC / Tools / bgen / dlg / tdlg_modeless.py < prev    next >
Encoding:
Python Source  |  1995-10-11  |  1019 b   |  46 lines  |  [TEXT/PYTH]

  1. # Function to display a message and wait for the user to hit OK.
  2. # This uses a DLOG resource with ID=256 which is part of the standard
  3. # Python library.
  4. # The ID can be overridden by passing a second parameter.
  5. # This is the modeless version of this test program, the normal
  6. # modal version is in tdlg.py
  7.  
  8. import addpack
  9. addpack.addpack(':Tools:bgen:evt')
  10.  
  11. from Dlg import *
  12. from Evt import *
  13. from Events import *
  14. import MacOS
  15. import string
  16.  
  17. ID = 256
  18.  
  19. def message(str = "Hello, modeless world!", id = ID):
  20.     print 'This is to init the console window...'
  21.     d = GetNewDialog(id, -1)
  22.     tp, h, rect = d.GetDialogItem(2)
  23.     SetDialogItemText(h, str)
  24.     while 1:
  25.         ok, ev = WaitNextEvent(0xffff, 10)
  26.         if not ok:
  27.             continue
  28.         if IsDialogEvent(ev):
  29.             ok, window, item = DialogSelect(ev)
  30.             if ok:
  31.                 if window == d:
  32.                     if item == 1:
  33.                         break
  34.                     else:
  35.                         print 'Unexpected item hit'
  36.                 else:
  37.                     print 'Unexpected dialog hit'
  38.         else:
  39.             MacOS.HandleEvent(ev)
  40.  
  41. def test():
  42.     message()
  43.  
  44. if __name__ == '__main__':
  45.     test()
  46.